home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / DIKUMUD.ZIP / SHOP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  19.4 KB  |  723 lines

  1. /*
  2.   SillyMUD Distribution V1.1b             (c) 1993 SillyMUD Developement
  3.  
  4.   See license.doc for distribution terms.   SillyMUD is based on DIKUMUD
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #include "protos.h"
  11.  
  12. #define SHOP_FILE "tinyworld.shp"
  13. #define MAX_TRADE 5
  14. #define MAX_PROD 5
  15.  
  16.  
  17. extern struct str_app_type str_app[];
  18. extern struct index_data *mob_index;
  19. extern struct chr_app_type chr_apply[];
  20.  
  21. char *fread_string(FILE *fl);
  22. char getall( char *name, char  *newname);
  23. int  getabunch( char *name, char  *newname);
  24. float  shop_multiplier = 0;
  25. int gevent = 0; /* Global Event happening currently */
  26.  
  27. struct shop_data
  28. {
  29.     int producing[MAX_PROD];/* Which item to produce (virtual)      */
  30.     float profit_buy;       /* Factor to multiply cost with.        */
  31.     float profit_sell;      /* Factor to multiply cost with.        */
  32.     byte type[MAX_TRADE];   /* Which item to trade.                 */
  33.     char *no_such_item1;    /* Message if keeper hasn't got an item */
  34.     char *no_such_item2;    /* Message if player hasn't got an item */
  35.     char *missing_cash1;    /* Message if keeper hasn't got cash    */
  36.     char *missing_cash2;    /* Message if player hasn't got cash    */
  37.     char *do_not_buy;    /* If keeper dosn't buy such things.     */
  38.     char *message_buy;      /* Message when player buys item        */
  39.     char *message_sell;     /* Message when player sells item       */
  40.     int temper1;               /* How does keeper react if no money    */
  41.     int temper2;               /* How does keeper react when attacked  */
  42.     int keeper;             /* The mobil who owns the shop (virtual)*/
  43.     int with_who;        /* Who does the shop trade with?    */
  44.     int in_room;        /* Where is the shop?            */
  45.     int open1,open2;    /* When does the shop open?        */
  46.     int close1,close2;    /* When does the shop close?        */
  47. };
  48.  
  49. #if HASH
  50. extern struct hash_header room_db;
  51. #else
  52. extern struct room_data *room_db;
  53. #endif
  54. extern struct time_info_data time_info;
  55.  
  56. struct shop_data *shop_index;
  57. int number_of_shops;
  58.  
  59. int is_ok(struct char_data *keeper, struct char_data *ch, int shop_nr)
  60. {
  61.     if (shop_index[shop_nr].open1>time_info.hours){
  62.         do_say(keeper,
  63.         "Come back later!",17);
  64.         return(FALSE);
  65.     } else if (shop_index[shop_nr].close1<time_info.hours)
  66.         if (shop_index[shop_nr].open2>time_info.hours){
  67.             do_say(keeper,
  68.             "Sorry, we have closed, but come back later.",17);
  69.             return(FALSE);
  70.         } else if (shop_index[shop_nr].close2<time_info.hours){
  71.             do_say(keeper,
  72.             "Sorry, come back tomorrow.",17);
  73.             return(FALSE);
  74.         };
  75.  
  76.     if(!(CAN_SEE(keeper,ch)))    {
  77.         do_say(keeper,
  78.         "I don't trade with someone I can't see!",17);
  79.         return(FALSE);
  80.     };
  81.  
  82.     switch(shop_index[shop_nr].with_who){
  83.         case 0 : return(TRUE);
  84.         case 1 : return(TRUE);
  85.         default : return(TRUE);
  86.     };
  87. }
  88.  
  89. int trade_with(struct obj_data *item, int shop_nr)
  90. {
  91.   int counter;
  92.   
  93.   if(item->obj_flags.cost < 1) return(FALSE);
  94.   
  95.   for(counter=0;counter<MAX_TRADE;counter++)
  96.     if(shop_index[shop_nr].type[counter]==item->obj_flags.type_flag)
  97.       return(TRUE);
  98.   return(FALSE);
  99. }
  100.  
  101. int shop_producing(struct obj_data *item, int shop_nr)
  102. {
  103.   int counter;
  104.   
  105.   if(item->item_number<0) return(FALSE);
  106.   
  107.   for(counter=0;counter<MAX_PROD;counter++)
  108.     if (shop_index[shop_nr].producing[counter] == item->item_number
  109.     )
  110.       return(TRUE);
  111.   return(FALSE);
  112. }
  113.  
  114. void shopping_buy( char *arg, struct char_data *ch,
  115.      struct char_data *keeper, int shop_nr)
  116. {
  117.   char argm[100], buf[MAX_STRING_LENGTH], newarg[100];
  118.   int num = 1;
  119.   struct obj_data *temp1;
  120.   int i;
  121.   float mult = 0;
  122.   
  123.   if(!(is_ok(keeper,ch,shop_nr)))
  124.     return;
  125.  
  126.   if(keeper->generic != 0)
  127.      for(i = 0; i <= MAX_TRADE; i++) {
  128.        if(keeper->generic == FAMINE)
  129.           if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
  130.             mult = shop_multiplier; /* we're in a famine, we sell food, so we */
  131.             break;             /* our prices to hell ;-) -DM */ 
  132.           }
  133.        if(keeper->generic == DWARVES_STRIKE)
  134.           if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
  135.           mult = shop_multiplier;
  136.           break;
  137.        }        
  138.      }
  139.   
  140.   only_argument(arg, argm);
  141.   if(!(*argm))   {
  142.       sprintf(buf,
  143.           "%s what do you want to buy??"
  144.           ,GET_NAME(ch));
  145.       do_tell(keeper,buf,19);
  146.       return;
  147.     };
  148.   
  149.   if ((num = getabunch(argm,newarg))!=NULL) {
  150.     strcpy(argm,newarg);
  151.   }
  152.   if (num == 0) num = 1;
  153.   
  154.   if(!( temp1 = 
  155.        get_obj_in_list_vis(ch,argm,keeper->carrying)))    {
  156.       sprintf(buf,
  157.           shop_index[shop_nr].no_such_item1
  158.           ,GET_NAME(ch));
  159.       do_tell(keeper,buf,19);
  160.       return;
  161.     }
  162.   
  163.   if(temp1->obj_flags.cost <= 0)    {
  164.       sprintf(buf,
  165.           shop_index[shop_nr].no_such_item1
  166.           ,GET_NAME(ch));
  167.       do_tell(keeper,buf,19);
  168.       extract_obj(temp1);
  169.       return;
  170.     }
  171.   
  172.   if (GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost*
  173.             shop_index[shop_nr].profit_buy -
  174.       ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
  175.          (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD)    {
  176.       sprintf(buf,
  177.           shop_index[shop_nr].missing_cash2,
  178.           GET_NAME(ch));
  179.       do_tell(keeper,buf,19);
  180.       
  181.       switch(shop_index[shop_nr].temper1)    {
  182.     case 0:
  183.       do_action(keeper,GET_NAME(ch),30);
  184.       return;
  185.     case 1:
  186.       do_emote(keeper,"grins happily",36);
  187.       return;
  188.     default:
  189.       return;
  190.     }
  191.     }
  192.   
  193.   if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch)))
  194.     {
  195.       sprintf(buf,"%s : You can't carry that many items.\n\r", 
  196.           fname(temp1->name));
  197.       send_to_char(buf, ch);
  198.       return;
  199.     }
  200.   
  201.   if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch))
  202.     {
  203.       sprintf(buf,"%s : You can't carry that much weight.\n\r", 
  204.           fname(temp1->name));
  205.       send_to_char(buf, ch);
  206.       return;
  207.     }
  208.   
  209.   act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM);
  210.   
  211.   sprintf(buf, shop_index[shop_nr].message_buy,
  212.       GET_NAME(ch), (int) (num * (temp1->obj_flags.cost*
  213.       shop_index[shop_nr].profit_buy -
  214.           ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + 
  215.           (mult * temp1->obj_flags.cost))));
  216.   
  217.   do_tell(keeper,buf,19);
  218.   
  219.   sprintf(buf,"You now have %s (*%d).\n\r",
  220.       temp1->short_description,num);
  221.   
  222.   send_to_char(buf,ch);
  223.   
  224.   while (num-- > 0) {
  225.     
  226.     if (GetMaxLevel(ch)<DEMIGOD)
  227.       GET_GOLD(ch) -= (int)(temp1->obj_flags.cost*
  228.         shop_index[shop_nr].profit_buy -
  229.         ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+
  230.                 (mult * temp1->obj_flags.cost));
  231.     
  232.       GET_GOLD(keeper) += (int)(temp1->obj_flags.cost*
  233.         shop_index[shop_nr].profit_buy -
  234.         ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+
  235.                 (mult * temp1->obj_flags.cost));
  236.     
  237.     /* Test if producing shop ! */
  238.     if (shop_producing(temp1,shop_nr))
  239.       temp1 = read_object(temp1->item_number, REAL);
  240.     else {
  241.       obj_from_char(temp1);
  242.       if (temp1 == NULL) {
  243.     send_to_char("Sorry, I just ran out of those.\n\r",ch);
  244.     GET_GOLD(ch) += (int)(temp1->obj_flags.cost*
  245.         shop_index[shop_nr].profit_buy -
  246.         ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+
  247.                 (mult * temp1->obj_flags.cost));
  248.     return;
  249.       }
  250.     }
  251.     
  252.     obj_to_char(temp1,ch);
  253.     
  254.   }
  255.   return; 
  256. }
  257.  
  258. void shopping_sell( char *arg, struct char_data *ch,
  259.            struct char_data *keeper,int shop_nr)
  260. {
  261.   char argm[100], buf[MAX_STRING_LENGTH];
  262.   int cost,temp_cost, i;
  263.   struct obj_data *temp1;
  264.   float mult = 0;
  265.   
  266.   if(!(is_ok(keeper,ch,shop_nr)))
  267.     return;
  268.  
  269.   if(keeper->generic != 0)
  270.      for(i = 0; i <= MAX_TRADE; i++) {
  271.        if(keeper->generic == FAMINE)
  272.           if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
  273.             mult = shop_multiplier; /* we're in a famine, we sell food, so we */
  274.             break;             /* our prices to hell ;-) -DM */ 
  275.           }
  276.        if(keeper->generic == DWARVES_STRIKE)
  277.           if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
  278.           mult = shop_multiplier;
  279.           break;
  280.        }        
  281.      }
  282.   
  283.   only_argument(arg, argm);
  284.   
  285.   if(!(*argm))    {
  286.     sprintf(buf, "%s What do you want to sell??"
  287.         ,GET_NAME(ch));
  288.     do_tell(keeper,buf,19);
  289.     return;
  290.   }
  291.   
  292.   if (!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) {
  293.     sprintf(buf, shop_index[shop_nr].no_such_item2,GET_NAME(ch));
  294.     do_tell(keeper,buf,19);
  295.     return;
  296.   }
  297.   
  298.   if (IS_OBJ_STAT(temp1, ITEM_NODROP)) {
  299.      send_to_char
  300.           ("You can't let go of it, it must be CURSED!\n\r", ch);
  301.      return;
  302.   }
  303.  
  304.   if (!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1)) {
  305.     sprintf(buf,shop_index[shop_nr].do_not_buy,
  306.         GET_NAME(ch));
  307.     do_tell(keeper,buf,19);
  308.     return;
  309.   }
  310.   
  311.   if (GET_GOLD(keeper)<(int) (temp1->obj_flags.cost*
  312.             shop_index[shop_nr].profit_sell +
  313.         ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
  314.                 (mult * temp1->obj_flags.cost)))
  315.  {
  316.     sprintf(buf,shop_index[shop_nr].missing_cash1,GET_NAME(ch));
  317.     do_tell(keeper,buf,19);
  318.     return;
  319.   }
  320.   
  321.   cost = temp1->obj_flags.cost;
  322.   
  323.   if ((ITEM_TYPE(temp1) == ITEM_WAND) ||
  324.       (ITEM_TYPE(temp1) == ITEM_STAFF)) {
  325.     if (temp1->obj_flags.value[1]) {
  326.       cost = (int)cost * (float)(temp1->obj_flags.value[2] /
  327.                  (float) temp1->obj_flags.value[1]);
  328.     } else {
  329.       cost = 0;
  330.     }
  331.   } else if (ITEM_TYPE(temp1) == ITEM_ARMOR) {
  332.     if (temp1->obj_flags.value[1]) {
  333.       cost = (int)cost * (float)(temp1->obj_flags.value[0] /
  334.                  (float)(temp1->obj_flags.value[1]));
  335.     } else {
  336.       cost = 0;
  337.     }
  338.   }
  339.   
  340.   temp1->obj_flags.cost = cost;
  341.   
  342.   act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM);
  343.   temp_cost = (int) (temp1->obj_flags.cost*shop_index[shop_nr].profit_sell +
  344.          ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
  345.              (mult * temp1->obj_flags.cost));
  346.   if(temp_cost < 0) temp_cost=0;
  347.  
  348.   sprintf(buf,shop_index[shop_nr].message_sell,GET_NAME(ch),temp_cost);
  349.  
  350. /* (int) (temp1->obj_flags.cost*    
  351.         shop_index[shop_nr].profit_sell +
  352.         ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)))
  353. ; */
  354.   
  355.   do_tell(keeper,buf,19);
  356.   
  357.   sprintf(buf,"The shopkeeper now has %s.\n\r",
  358.       temp1->short_description);
  359.   send_to_char(buf,ch);
  360.   
  361.   if (GET_GOLD(keeper)< temp_cost) {
  362.  /* (int) (temp1->obj_flags.cost*
  363.           shop_index[shop_nr].profit_sell +
  364.            ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100))) {
  365.  */
  366.     sprintf(buf,shop_index[shop_nr].missing_cash1 ,GET_NAME(ch));
  367.     do_tell(keeper,buf,19);
  368.     return;
  369.   }
  370.   
  371.   GET_GOLD(ch) += temp_cost;
  372.     /* (int) (temp1->obj_flags.cost*
  373.           shop_index[shop_nr].profit_sell +
  374.            ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
  375.           */
  376.   GET_GOLD(keeper) -= temp_cost;
  377.     /* (int) (temp1->obj_flags.cost*
  378.           shop_index[shop_nr].profit_sell +
  379.            ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
  380.           */
  381.   obj_from_char(temp1);
  382.   if (temp1 == NULL) {
  383.     send_to_char("As far as I am concerned, you are out..\n\r",ch);
  384.     return;
  385.   }
  386.   if ((get_obj_in_list(argm,keeper->carrying)) || 
  387.       (GET_ITEM_TYPE(temp1) == ITEM_TRASH)) {
  388.     extract_obj(temp1);
  389.   } else {
  390.     obj_to_char(temp1,keeper);
  391.   }
  392.   return;
  393. }
  394.  
  395. void shopping_value( char *arg, struct char_data *ch, 
  396.             struct char_data *keeper, int shop_nr)
  397. {
  398.   char argm[100], buf[MAX_STRING_LENGTH];
  399.   struct obj_data *temp1;
  400.   int i;
  401.   float mult = 0;
  402.   
  403.   if(!(is_ok(keeper,ch,shop_nr)))
  404.     return;
  405.  
  406.   if(keeper->generic != 0)
  407.      for(i = 0; i <= MAX_TRADE; i++) {
  408.        if(keeper->generic == FAMINE)
  409.           if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
  410.             mult = shop_multiplier; /* we're in a famine, we sell food, so we */
  411.             break;             /* our prices to hell ;-) -DM */ 
  412.           }
  413.        if(keeper->generic == DWARVES_STRIKE)
  414.           if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
  415.           mult = shop_multiplier;
  416.           break;
  417.        }        
  418.      }
  419.   
  420.   only_argument(arg, argm);
  421.   
  422.   if(!(*argm))    {
  423.       sprintf(buf,"%s What do you want me to evaluate??",
  424.           GET_NAME(ch));
  425.       do_tell(keeper,buf,19);
  426.       return;
  427.     }
  428.   
  429.   if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))    {
  430.       sprintf(buf,shop_index[shop_nr].no_such_item2,
  431.           GET_NAME(ch));
  432.       do_tell(keeper,buf,19);
  433.       return;
  434.     }
  435.   
  436.   if(!(trade_with(temp1,shop_nr)))    {
  437.       sprintf(buf,
  438.           shop_index[shop_nr].do_not_buy,
  439.           GET_NAME(ch));
  440.       do_tell(keeper,buf,19);
  441.       return;
  442.     }
  443.   
  444.   sprintf(buf,"%s I'll give you %d gold coins for that!",
  445.       GET_NAME(ch),(int) (temp1->obj_flags.cost*
  446.           shop_index[shop_nr].profit_sell +
  447.            ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
  448.               (mult * temp1->obj_flags.cost)));
  449.   do_tell(keeper,buf,19);
  450.   
  451.   return;
  452. }
  453.  
  454. void shopping_list( char *arg, struct char_data *ch,
  455.            struct char_data *keeper, int shop_nr)
  456. {
  457.   char buf[MAX_STRING_LENGTH], buf2[100],buf3[100];
  458.   struct obj_data *temp1;
  459.   extern char *drinks[];
  460.   int found_obj;
  461.   int i;
  462.   float mult = 0;
  463.   
  464.   if(!(is_ok(keeper,ch,shop_nr)))
  465.     return;
  466.  
  467.  
  468.   if(keeper->generic != 0)
  469.      for(i = 0; i <= MAX_TRADE; i++) {
  470.        if(keeper->generic == FAMINE)
  471.           if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
  472.             mult = shop_multiplier; /* we're in a famine, we sell food, so we */
  473.             break;             /* our prices to hell ;-) -DM */ 
  474.           }
  475.        if(keeper->generic == DWARVES_STRIKE)
  476.           if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
  477.           mult = shop_multiplier;
  478.           break;
  479.        }        
  480.      }
  481.   
  482.   strcpy(buf,"You can buy:\n\r");
  483.   found_obj = FALSE;
  484.   if(keeper->carrying)
  485.     for(temp1=keeper->carrying;
  486.     temp1; 
  487.     temp1 = temp1->next_content)
  488.       if((CAN_SEE_OBJ(ch,temp1)) && (temp1->obj_flags.cost>0))    {
  489.     found_obj = TRUE; 
  490.     if(temp1->obj_flags.type_flag != ITEM_DRINKCON) 
  491.       sprintf(buf2,"%s for %d gold coins.\n\r" ,(temp1->short_description),(int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy  - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)));
  492.  
  493.       else {
  494.         if (temp1->obj_flags.value[1])
  495.           sprintf(buf3,"%s of %s",(temp1->short_description)
  496.               ,drinks[temp1->obj_flags.value[2]]);
  497.         else
  498.           sprintf(buf3,"%s",(temp1->short_description));
  499.         sprintf(buf2,"%s for %d gold coins.\n\r",buf3,
  500.             (int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy -  ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)));
  501.       }
  502.       strcat(buf,CAP(buf2));
  503.     };
  504.   
  505.   if(!found_obj)
  506.     strcat(buf,"Nothing!\n\r");
  507.   
  508.   send_to_char(buf,ch);
  509.   return;
  510. }
  511.  
  512. void shopping_kill( char *arg, struct char_data *ch,
  513.            struct char_data *keeper, int shop_nr)
  514. {
  515.   char buf[100];
  516.   
  517.   switch(shop_index[shop_nr].temper2){
  518.   case 0:
  519.     sprintf(buf,"%s Don't ever try that again!",
  520.         GET_NAME(ch));
  521.     do_tell(keeper,buf,19);
  522.     return;
  523.     
  524.   case 1:
  525.     sprintf(buf,"%s Scram - midget!",
  526.         GET_NAME(ch));
  527.     do_tell(keeper,buf,19);
  528.     return;
  529.     
  530.     default :
  531.       return;
  532.   }
  533. }
  534.  
  535.  
  536. int shop_keeper(struct char_data *ch, int cmd, char *arg, char *mob, int type)
  537. {
  538.   char argm[100], buf[MAX_STRING_LENGTH];
  539.   struct char_data *temp_char;
  540.   struct char_data *keeper;
  541.   int shop_nr;
  542.   
  543.   int citizen(struct char_data *ch, int cmd, char *arg, struct char_data *mob, int type);
  544.  
  545.   if(type == EVENT_DWARVES_STRIKE) {
  546.     ch->generic = DWARVES_STRIKE;
  547.     return;  
  548.   }
  549.  
  550.   if(type == EVENT_FAMINE) {
  551.     ch->generic = FAMINE;
  552.     return;
  553.   }
  554.  
  555.   keeper = 0;
  556.   
  557.   for (temp_char = real_roomp(ch->in_room)->people; (!keeper) && (temp_char) ; 
  558.        temp_char = temp_char->next_in_room)
  559.     if (IS_MOB(temp_char))
  560.       if (mob_index[temp_char->nr].func == shop_keeper)
  561.     keeper = temp_char;
  562.   
  563.   
  564.   
  565.   for(shop_nr=0 ; shop_index[shop_nr].keeper != keeper->nr; shop_nr++);
  566.   
  567.   
  568.   if (!cmd) {
  569.     if (keeper->specials.fighting) {
  570.       return(citizen(keeper,0,"", keeper,0));
  571.     }
  572.   }
  573.   
  574.   if((cmd == 56) && (ch->in_room == shop_index[shop_nr].in_room))
  575.     /* Buy */
  576.     {
  577.       shopping_buy(arg,ch,keeper,shop_nr);
  578.       return(TRUE);
  579.     }
  580.   
  581.   if((cmd ==57 ) && (ch->in_room == shop_index[shop_nr].in_room))
  582.     /* Sell */
  583.     {
  584.       shopping_sell(arg,ch,keeper,shop_nr);
  585.       return(TRUE);
  586.     }
  587.   
  588.   if((cmd == 58) && (ch->in_room == shop_index[shop_nr].in_room))
  589.     /* value */
  590.     {
  591.       shopping_value(arg,ch,keeper,shop_nr);
  592.       return(TRUE);
  593.     }
  594.   
  595.   if((cmd == 59) && (ch->in_room == shop_index[shop_nr].in_room))
  596.     /* List */
  597.     {
  598.       shopping_list(arg,ch,keeper,shop_nr);
  599.       return(TRUE);
  600.     }
  601.   
  602.   if ((cmd == 25) || (cmd==70))   /* Kill or Hit */
  603.     {
  604.       only_argument(arg, argm);
  605.       
  606.       if (keeper == get_char_room(argm,ch->in_room))
  607.     {
  608.       shopping_kill(arg,ch,keeper,shop_nr);
  609.       return(TRUE);
  610.     }
  611.     } else if ((cmd==84) || (cmd==207) || (cmd==172)) {   /* Cast, recite, use */
  612.       act("$N tells you 'No magic here - kid!'.", FALSE, ch, 0, keeper, TO_CHAR);
  613.       return TRUE;
  614.     }
  615.   
  616.   return(FALSE);
  617. }
  618.  
  619. void boot_the_shops()
  620. {
  621.   char *buf;
  622.   int temp;
  623.   int count;
  624.   FILE *shop_f;
  625.   
  626.   if (!(shop_f = fopen(SHOP_FILE, "r")))
  627.     {
  628.       perror("Error in boot shop\n");
  629.       exit(0);
  630.     }
  631.   
  632.   number_of_shops = 0;
  633.   
  634.   for(;;)    {
  635.     buf = fread_string(shop_f);
  636.     if(*buf == '#')    /* a new shop */    {
  637.       if(!number_of_shops)    /* first shop */
  638.     CREATE(shop_index, struct shop_data, 1);
  639.       else
  640.     if(!(shop_index=
  641.          (struct shop_data*) realloc(
  642.                      shop_index,(number_of_shops + 1)*
  643.                      sizeof(struct shop_data)))) {
  644.       perror("Error in boot shop\n");
  645.       exit(0);
  646.     }
  647.       
  648.       for(count=0;count<MAX_PROD;count++)
  649.     {
  650.       fscanf(shop_f,"%d \n", &temp);
  651.       if (temp >= 0)
  652.         shop_index[number_of_shops].producing[count]=
  653.           real_object(temp);
  654.       else
  655.         shop_index[number_of_shops].producing[count]= temp;
  656.     }
  657.       fscanf(shop_f,"%f \n",
  658.          &shop_index[number_of_shops].profit_buy);
  659.       fscanf(shop_f,"%f \n",
  660.          &shop_index[number_of_shops].profit_sell);
  661.       for(count=0;count<MAX_TRADE;count++)
  662.     {
  663.       fscanf(shop_f,"%d \n", &temp);
  664.       shop_index[number_of_shops].type[count] =
  665.         (byte) temp;
  666.     }
  667.       shop_index[number_of_shops].no_such_item1 =
  668.     fread_string(shop_f);
  669.       shop_index[number_of_shops].no_such_item2 =
  670.     fread_string(shop_f);
  671.       shop_index[number_of_shops].do_not_buy =
  672.     fread_string(shop_f);
  673.       shop_index[number_of_shops].missing_cash1 =
  674.     fread_string(shop_f);
  675.       shop_index[number_of_shops].missing_cash2 =
  676.     fread_string(shop_f);
  677.       shop_index[number_of_shops].message_buy =
  678.     fread_string(shop_f);
  679.       shop_index[number_of_shops].message_sell =
  680.     fread_string(shop_f);
  681.       fscanf(shop_f,"%d \n",
  682.          &shop_index[number_of_shops].temper1);
  683.       fscanf(shop_f,"%d \n",
  684.          &shop_index[number_of_shops].temper2);
  685.       fscanf(shop_f,"%d \n",
  686.          &shop_index[number_of_shops].keeper);
  687.       
  688.       shop_index[number_of_shops].keeper =
  689.     real_mobile(shop_index[number_of_shops].keeper);
  690.       
  691.       fscanf(shop_f,"%d \n",
  692.          &shop_index[number_of_shops].with_who);
  693.       fscanf(shop_f,"%d \n",
  694.          &shop_index[number_of_shops].in_room);
  695.       fscanf(shop_f,"%d \n",
  696.          &shop_index[number_of_shops].open1);
  697.       fscanf(shop_f,"%d \n",
  698.          &shop_index[number_of_shops].close1);
  699.       fscanf(shop_f,"%d \n",
  700.          &shop_index[number_of_shops].open2);
  701.       fscanf(shop_f,"%d \n",
  702.          &shop_index[number_of_shops].close2);
  703.       
  704.       number_of_shops++;
  705.     }
  706.     else 
  707.       if(*buf == '$')    /* EOF */
  708.     break;
  709.   }
  710.   
  711.   fclose(shop_f);
  712. }
  713.  
  714. void assign_the_shopkeepers()
  715. {
  716.   int temp1;
  717.   
  718.   for(temp1=0 ; temp1<number_of_shops ; temp1++)
  719.     mob_index[shop_index[temp1].keeper].func = shop_keeper;
  720.   
  721. }
  722.  
  723.